#ifndef REMITABLE_H
#define REMITABLE_H

#include <QWidget>
#include <QTreeWidget>
#include <QDebug>
#include <QMouseEvent>
#include <QtSql>
#include <QInputDialog>
#include <QMessageBox>
#include <QSound>
#include "spinboxdelegate.h"
#include "decipheraddon.h"
#include "paketitem.h"
#include "remiitem.h"

namespace Ui {
class RemiTable;
}

class RemiTable : public QTreeWidget
{
    Q_OBJECT
    
public:
    explicit RemiTable();
    ~RemiTable();
    void loadRemiFromDatabase();
    RemiItem* getLastEditedRemi();
    RemiItem* getRemi(int id);
    void addRemi(QString gtin, QString addon, int menge);
    PaketItem* getPaket(int id);

public Q_SLOTS:
    bool newPackage();
    void removeSelectedRemis();

private Q_SLOTS:
    void editRemi(QTreeWidgetItem *item, int column);
    void remiEdited(QTreeWidgetItem *item, int column);
    void markLastRemi();
    void updateView();

Q_SIGNALS:
    void tableChanged();

protected:
    void dragMoveEvent(QDragMoveEvent *event);
    void dropEvent(QDropEvent *event);
    void showEvent(QShowEvent *);
    
private:
    QSqlDatabase db;
    DecipherAddon da;
    QMap<int, PaketItem*> pakete;
};

#endif // REMITABLE_H
